package com.mycompany.lctwitter.persist.dao;

import org.springframework.stereotype.Repository;
import org.springside.modules.orm.hibernate.HibernateDao;

import com.mycompany.lctwitter.persist.model.User;

@Repository("userDao")
public class UserDao extends HibernateDao<User, Long> {

    public User login(String userName, String pwd) {
        return findUnique("from User where userName=? and pwd=?", new Object[] { userName, pwd });
    }

    public User add(String userName, String pwd) {
        User user = new User();
        user.setUserName(userName);
        user.setPwd(pwd);
        save(user);
        return user;
    }

    public User find(String userName) {
        return findUnique("from User u where u.userName=?", new Object[] { userName });
    }

}
